//
//  GJFMerchantDetailHeaderView.m
//  Wedding
//
//  Created by 郭静芬 on 2017/1/2.
//  Copyright © 2017年 郭静芬. All rights reserved.
//

#import "GJFMerchantDetailHeaderView.h"

@interface GJFMerchantDetailHeaderView ()
@property (nonatomic, strong) UIView *view;
@property (nonatomic, strong) UIImageView *imageVV;

@end

@implementation GJFMerchantDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self imageV];
        [self view];
        [self imageVV];
        [self name];
        [self imageUser];
    }
    return self;
}

- (void)refreshFrameWithOffset:(CGFloat)offset_y {
    self.imageV.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height - 30 * YY);
    self.view.frame = self.imageV.frame;
    self.name.frame = CGRectMake(10, self.bounds.size.height - HEADERHEIGHT / 2 - 30 * YY, WIDTH - 20 * XX, 30 * YY);
    
    CGFloat hh = 30 * YY + offset_y / HEADERHEIGHT * 30;
    self.imageVV.frame = CGRectMake(0, self.imageV.frame.size.height - hh, self.frame.size.width, hh);
    self.imageUser.frame = CGRectMake(self.center.x - 30 * XX, self.bounds.size.height - 65 * YY, 60 * YY, 60 * YY);
}

- (UIView *)view {
    if (!_view) {
        _view = [[UIView alloc] init];
        _view.backgroundColor = [UIColor blackColor];
        _view.alpha = 0.3;
        [self addSubview:_view];
    }
    return _view;
}
- (UIImageView *)imageV {
    if (!_imageV) {
        _imageV = [[UIImageView alloc] init];
        _imageV.contentMode = UIViewContentModeScaleAspectFill;
        _imageV.clipsToBounds = YES;
        [self addSubview:_imageV];
    }
    return _imageV;
}
- (UILabel *)name {
    if (!_name) {
        _name = [[UILabel alloc] init];
        _name.textColor = [UIColor whiteColor];
        _name.font = [UIFont boldSystemFontOfSize:25 * XX];
        _name.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_name];
    }
    return _name;
}
- (UIImageView *)imageVV {
    if (!_imageVV) {
        _imageVV = [[UIImageView alloc] init];
        _imageVV.image = [UIImage imageNamed:@"椭半圆"];
        [self addSubview:_imageVV];
    }
    return _imageVV;
}
- (UIImageView *)imageUser {
    if (!_imageUser) {
        _imageUser = [[UIImageView alloc] init];
        _imageUser.layer.cornerRadius = 30 * YY;
        _imageUser.clipsToBounds = YES;
        _imageUser.layer.borderColor = HOMECOLOR.CGColor;
        _imageUser.layer.borderWidth = 2;
        [self addSubview:_imageUser];
    }
    return _imageUser;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
